home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / tcplusx.zip / DEVICE.CPP < prev    next >
C/C++ Source or Header  |  1991-02-28  |  3KB  |  131 lines

  1. //
  2. // device.cpp    - implementation for class Device
  3. // Author        - Robin W. McKean
  4. // Last Update    - February 19,1991
  5. // Copyright (C) 1991 All rights reserved
  6. //
  7. // This file remains the property of the author, Robin W. McKean.  You are
  8. // free to use and change it as you see fit.  This module, nor its object
  9. // code, may not however be included  in any packaged software without the
  10. // written consent of the author.
  11. //
  12.  
  13. // Contents ----------------------------------------------------------------
  14. //
  15. //        Device::Device
  16. //        Device::isEqual
  17. //        Device::printOn
  18. //
  19. // Description
  20. //
  21. //      Defines the class Device.  The purpose of this class is to input
  22. //      information from a device and translate it into events.  This is
  23. //        an abstract class from which other device types are made.
  24. //            
  25. // End ---------------------------------------------------------------------
  26.  
  27. // Interface dependencies --------------------------------------------------
  28.  
  29. #ifndef _IOSTREAM_H
  30. #include <iostream.h>
  31. #endif
  32.  
  33. #ifndef _USETYPES_H
  34. #include <usetypes.h>
  35. #endif
  36.  
  37. #ifndef _GEN_H
  38. #include <gen.h>
  39. #endif
  40.  
  41. #ifndef _EVENT_H
  42. #include <event.h>
  43. #endif
  44.  
  45. #ifndef _DEVICE_H
  46. #include <device.h>
  47. #endif
  48.  
  49. // End Interface dependencies ----------------------------------------------
  50.  
  51. // Member Function //
  52.  
  53. Device::Device( int initStatus )
  54.  
  55. // Summary ------------------------------------------------------------------
  56. //
  57. //        Sets the initial status of the device
  58. //
  59. // End ---------------------------------------------------------------------
  60. {
  61.     status = initStatus;
  62. }
  63.  
  64. // End Device::Device //
  65.  
  66. // Member Function //
  67.  
  68. Device::Device( Device& theDevice )
  69.  
  70. // Description -------------------------------------------------------------
  71. //
  72. //        Copies one device into another
  73. //
  74. // Parameters
  75. //
  76. //        Device&
  77. //
  78. //        The device to be copied
  79. //
  80. // End ---------------------------------------------------------------------
  81. {
  82.     status = theDevice.status;
  83. }
  84.  
  85. // End Device::Device( Device& ) //
  86.  
  87. // Member Function //
  88.  
  89. hashValueType Device::hashValue( ) const
  90.  
  91. // Description -------------------------------------------------------------
  92. //
  93. //        Returns a hash value representation of a class, in this case, there
  94. //        is none, so we return 0.
  95. //
  96. // End ---------------------------------------------------------------------
  97. {
  98.     return hashValueType( 0 );
  99. }
  100.  
  101. // End Device::hashValue //
  102.  
  103. int Device::isEqual( const Object& theDevice ) const
  104.  
  105. // Description -------------------------------------------------------------
  106. //
  107. //        Returns a 1 if this object is equal to the event
  108. //
  109. // End ---------------------------------------------------------------------
  110. {
  111.     return( isA() == theDevice.isA() && status == ( ( Device& )theDevice ).status );
  112. }
  113.  
  114. // End Device::isEqual //
  115.  
  116. // Member Function //
  117.  
  118. void Device::printOn( ostream& outputStream ) const
  119.  
  120. // Description -------------------------------------------------------------
  121. //
  122. //        Prints the contents of this object to the outputStream
  123. //
  124. // End ---------------------------------------------------------------------
  125. {
  126.     outputStream << nameOf() << "  " << "Status: " << status;
  127.  
  128. }
  129.  
  130. // End Device::printOn //
  131.